home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / ov143b.zip / FILE.C < prev    next >
C/C++ Source or Header  |  1993-01-04  |  2KB  |  67 lines

  1. /*  007  17-Jan-87  file.c
  2.  
  3.         Functions to work on/with DOS files.
  4.  
  5.         Copyright (c) 1987 by Blue Sky Software.  Alll rights reserved.
  6. */
  7.  
  8. #include <dos.h>
  9. #include "dosfile.h"
  10.  
  11. #ifndef NULL
  12. #define NULL (0)
  13. #endif
  14.  
  15. #ifndef TRUE
  16. #define TRUE (1)
  17. #define FALSE (0)
  18. #endif
  19.  
  20. static struct search_block search_blk;
  21.  
  22.  
  23. /******************************************************************************
  24.  **                            N X T F I L E                                 **
  25.  *****************************************************************************/
  26.  
  27. struct search_block *
  28. nxtfile(fn,mask,firstp)        /* find the first/next file matching fn and */
  29. char *fn;                      /*   the attribute mask */
  30. unsigned mask;
  31. int *firstp;
  32. {
  33.  
  34. #define SEARCH_FIRST    0x4E00
  35. #define SEARCH_NEXT     0x4F00
  36.  
  37.    union REGS r;
  38.  
  39.    bdos(0x1a,(unsigned int)&search_blk,0);   /* set the DTA addr for search's */
  40.  
  41.    r.x.ax = *firstp ? SEARCH_FIRST : SEARCH_NEXT;  /* fisrt/next flag */
  42.    *firstp = FALSE;
  43.  
  44.    r.x.cx = mask;                      /* caller specifies file search mask */
  45.    r.x.dx = (int) fn;                  /* the file name to search for */
  46.    intdos(&r,&r);                      /* let dos do the looking */
  47.  
  48.    if (r.x.cflag)                      /* cflag means error (no more files) */
  49.       return(NULL);                    /*   return NULL if no name */
  50.    else
  51.       return(&search_blk);             /* otherwise, return search block addr */
  52.  
  53. }
  54.  
  55.  
  56. /*****************************************************************************
  57.                          A L L O C _ S I Z
  58.  *****************************************************************************/
  59.  
  60. unsigned long
  61. alloc_siz(used,clustersiz)     /* calc the allocated size of a file */
  62. unsigned long used;
  63. unsigned int clustersiz;
  64. {
  65.    return( (used + clustersiz - 1) & ~((long)(clustersiz-1)) );
  66. }
  67.